Skip to content

Prevent follower control from overriding battery temperature shutdown - #144

Open
Solarboaters wants to merge 2 commits into
LibreSolar:mainfrom
Solarboaters:fix/follower-temperature-stop
Open

Solarboaters wants to merge 2 commits into
LibreSolar:mainfrom
Solarboaters:fix/follower-temperature-stop

Conversation

@Solarboaters

@Solarboaters Solarboaters commented Nov 12, 2026 •

Copy link
Copy Markdown

A recent external control message can override the battery charge-temperature shutdown in the same charge_control() call. The temperature checks first set the current limit to zero and enter IDLE. Execution then continues into the follower transition when time_last_ctrl_msg is recent, and the FOLLOWER case restores the positive target_current_control even though the battery remains outside its temperature limits. This also happens when the charger was already following external control.

Return immediately after either temperature shutdown so the remainder of the state machine cannot undo it. Add a regression test covering overtemperature and undertemperature from IDLE, BULK and FOLLOWER, checking the idle state, zero allowed charging current and corresponding error flag.

Validation:

  • Compiled and ran the actual extracted charge_control() and enter_state() methods against the production Charger, PowerPort and DcBus headers, with simulated uptime and error-status interfaces.
  • The original code fails the temperature-stop assertion with a recent external control message.
  • The patch passes all six temperature/state combinations, plus normal follower control and recovery after cooling.
  • git diff --check passes.

The Zephyr/Unity suite has been extended but was not run here. A full firmware build and physical hardware tests remain pending. No hardware charging behaviour is claimed from this host reproduction.

Evidence audit — 17 November 2026

Individually rebuilt and ran the production Zephyr native test image from public revision 4632ae0: 96 tests, zero failures. This is separate from the combined run of #135–#145, which passes all 103 tests. Replacing the relevant production implementations with the original code reproduces the new regression failures.

Reproduction in the west workspace, from the firmware directory:

ZEPHYR_TOOLCHAIN_VARIANT=host west build -b native_sim/native/64 -d ../build tests -- -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -DDTC_OVERLAY_FILE=boards/native_sim.overlay
../build/zephyr/zephyr.exe

Environment: Linux x86-64, GCC host toolchain, Zephyr 4.4.2, manifest dependencies. These tests use the project's native simulated interfaces; no ARM board or charging hardware was operated.

The audit also corrected fixture isolation: initialization clears the prior controller-message timestamp and current target, so the follower test cannot affect later charging-state tests.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant